/*******************************************************************************
 PIC32 Host Bus Interface Driver

  Company:
    Microchip Technology Inc.

  File Name:
    PMPDriver.h

  Summary:
    Contains the Header File of PIC32 Host Bus Interface Driver

  Description:
    This file contains the Header File of PIC32 Host Bus Interface Driver

  Change History:
    Version		Changes
	0.1			Initial version.
	1.3			Re-arranged the functions.
*******************************************************************************/

/*******************************************************************************
Copyright (c) 2015 released Microchip Technology Inc.  All rights reserved.

Microchip licenses to you the right to use, modify, copy and distribute
Software only when embedded on a Microchip microcontroller or digital signal
controller that is integrated into your product or third party product
(pursuant to the sublicense terms in the accompanying license agreement).

You should refer to the license agreement accompanying this Software for
additional information regarding your rights and obligations.

SOFTWARE AND DOCUMENTATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
 *******************************************************************************/

// *****************************************************************************
// *****************************************************************************
// Section: Included Files
// *****************************************************************************
// *****************************************************************************

#ifndef PMPDRIVER_H
#define	PMPDRIVER_H

#ifdef	__cplusplus
extern "C" {
#endif
	
#include "stdint.h"
#include "ecat_def.h"
	
#define LAN9252_ID_REV                  0X50
#define LAN9252_BYTE_ORDER_REG          0x64
#define LAN9252_CSR_INT_CONF            0x54
#define LAN9252_CSR_INT_EN              0x5C
#define LAN9252_CSR_INT_STS             0x58
	
	
typedef union
{
	uint32_t Val;
	uint8_t v[4];
	uint16_t w[2];
	struct
	{
		uint8_t LB;
		uint8_t HB;	
		uint8_t UB;
		uint8_t MB;
	}byte;
}UINT32_VAL;


typedef union
{
	uint16_t Val;
	struct
	{
		uint8_t LB;
		uint8_t HB;	
	}byte;
}UINT16_VAL;


#define		HBI_INDEXED_16BIT  1

#ifdef HBI_INDEXED_8BIT
    #define HBI_MODE INDEXED_8BIT
    #define HBI_INDEXED_MODE
#elif HBI_INDEXED_16BIT
    #define HBI_MODE INDEXED_16BIT
    #define HBI_INDEXED_MODE
#elif HBI_MDP_8BIT
    #define HBI_MODE MDP_8BIT
#elif HBI_MDP_16BIT
    #define HBI_MODE MDP_16BIT
#elif HBI_MSP_8BIT
    #define HBI_MODE MSP_8BIT
#elif HBI_MSP_16BIT
    #define HBI_MODE MSP_16BIT
#else
    #error "Set one of the HBI modes in project setting"
#endif

    void PMPReadDRegister(UINT8 *ReadBuffer, UINT16 Address, UINT16 Count);
    void PMPWriteRegister( UINT8 *WriteBuffer, UINT16 Address, UINT16 Count);
    void PMPReadPDRamRegister(UINT8 *ReadBuffer, UINT16 Address, UINT16 Count);
    void PMPWritePDRamRegister(UINT8 *WriteBuffer, UINT16 Address, UINT16 Count);
    UINT32 PDIReadLAN9252DirectReg(UINT16 Address);
    void PDIWriteLAN9252DirectReg( UINT32 Val, UINT16 Address);
		void PMPWriteDWord (UINT16 Address, UINT32 Val);
		UINT32 PMPReadDWord (UINT16 Address);
    void DAC_Configration(void);
		void TIM14_PWM_Init(uint32_t PeriodValue,uint32_t PrescalerValue);
		void Dac1_Set_Var(uint16_t var);
#ifdef	__cplusplus
}
#endif

#endif	/* PMPDRIVER_H */

